

<!--sidebar-menu-->
<div id="sidebar" class="clearfix"><!-- <a href="#" class="visible-phone"><i class="icon icon-home"></i> Dashboard</a> -->
  <ul style="display: block;">
  {% include "common/menu.html" %}
  </ul>
</div>
<!--end sidebar-menu-->

<div id="content">

    <div class="container-fluid" style="padding: 0;">

      <div class="widget-box tab-tabs" >
          <div class="widget-title">
              <ul class="nav nav-tabs">
                  {% include "common/tab.html" %}
              </ul>
          </div>
          <div id="encryptionDIV" class="widget-content tab-content hidden">
            <div id="tab1" class="tab-pane active">
              <div class="container-fluid">
                  <div class="row-fluid" style="margin: 20px 0;overflow: hidden;">
                      <!-- <span style="font-size:20px;">“托”账号：此类账号送出的礼物等，计入成长值， 不计入收益</span> -->
                  </div>
                  <div class="row-fluid">
                    <div class="content-box content-box-padding" >
                      <p style="font-size:20px;">主播每个月可以收到的所有推广员送礼的收益所占保底底薪的比例</p>
                      <span id="limitNum" class="font font20 cr-ly"><input id="ratioNum" value='{{ ratioNum }}' style="display:none;" />{{ ratioNum }}%</span>
                      <button type="button" class="btn btn-purple pull-right" style="" onclick="changeRatio()">修改</button>
                    </div>
                  </div>
                  <div class="row-fluid" style="margin-top: 20px;">
                    <div class="content-box content-box-padding" >
                      <span style="font-size:20px;">每日限额（所有推广员每天可送礼的聊币总额）：</span>
                      <span id="totalCashNum" class="font font20 cr-ly"><input id="totalCash" value='{{ limitNum }}' style="display:none;" />
                          {% if limitNum != '' %}
                            {{ limitNum }}聊币
                          {% else %}
                            无
                          {% endif %}
                      </span>
                      <button type="button" class="btn btn-purple pull-right" style="" onclick="totalCashRatio()">修改</button>
                    </div>
                  </div>
                  <div class="row-fluid" style="margin: 20px 0;overflow: hidden;">
                    <form id="fiamlyform" class="form-search">
                      <span class="find-search pull-right">
                      <i class="icon-search icon-on-right bigger-110"></i>
                      <input name="name" type="text" placeholder="用户名（uid）或昵称" >
                      <button id="btn_search" type="button" class="btn btn-purple">搜索</button>
                      </span>
                    </form>
                  </div>

                  {% include "common/pagination.html" %}

                <div class="row-fluid">
                  <table id="tableList" class="table with-check table-purple">
                    <thead>
                      <tr>
                        <th>主播账号</th>
                        <th>昵称</th>
                        <th>富家等级&uarr;&darr;</th>
                        <th class="cursor">账户余额(聊币)&uarr;&darr;</th>
                        <th></th>
                      </tr>
                    </thead>
                    <tbody>

                    </tbody>
                  </table>
                </div>

              </div>
            </div>
         </div>
        </div>
    </div>
</div>
<div id="enterPwd" style="display:none">
    <!--class="ui-dialog"-->
    <form id="enterPwdForm">
        <div>
            密码：
            <input type="password" value='' id="pwd"></div>
        <input id='hideuid' type="hidden"></form>
</div>
<script type="text/javascript">
    $('#enterPwd').on('keypress',function(e){
        e = e || window.event;
        if(13 == e.keyCode){
            var uid = $("#hideuid").attr('data');
            aa(uid);
            e.returnValue = false
            return false
        }
    });
    var uid = '{{info['uid']}}';
    enterPwd(uid);
    function enterPwd(uid){
        var postData = {};
        postData.type = 0;
        $.ajax({
            type:"POST",
            data:postData,
            url:'/ajax/checkHasAuth',
            dataType:'json',
            success:function(res){
                if(res.code == 0){
                    $("#encryptionDIV").removeClass('hidden');
                }else{
                    // var pwd = window.prompt("输入密码", "");
                    // aa(uid,pwd);
                    $('#enterPwd').dialog({
                        autoOpen:true,
                        width:320,
                        height:180,
                        title:'输入密码',
                        resizable:false,
                        modal:true,
                        open:function(){
                            $('#hideuid').attr('data',uid);
                        },
                        buttons: {
                            "确定": function () {
                                // $(".ui-dialog-titlebar-close").click();
                                aa(uid);
                            }
                        }
                    });
                }
            }
        });
    }
    function aa(uid,pwd){
        var data={};
        data.pwd = $('#pwd').val();
        data.type = 0;
        $.ajax({
            type:"POST",
            data:data,
            url:'/ajax/checkAnchorPwd',
            dataType:'json',
            success:function(res){
                if(res.code == 0){
                    location.reload();
                }else{
                    if(confirm(res.info) == false){
                        $("#encryptionDIV").addClass('hidden');
                    }else{
                        $("#encryptionDIV").addClass('hidden');
                    }
                }
            }
        });
    }
</script>
<div id="ruleDialog" style="display:none"> <!--class="ui-dialog"-->
    <form id="ruleDialogForm">
        <div>
            <span>满足以下</span>
            <select name="conditions" style="width: 110px;">
                <option value="2">全部且</option>
                <option value="1">任意或</option>
            </select>
            <span>条件</span>
            <button id="btnConditions" type="button" class="btn btn-purple" style="height: 30px;">添加条件</button>
        </div>
        <div style="height: 210px;width: 665px;border-radius: 4px;background-color: #f9f9f9;margin: 10px auto 30px;border: 1px solid #cccccc;overflow:auto;">
            <div id="conditionsclone" style="display: none">
                <div class="conditions-box" style="height: 40px;line-height: 40px;border-bottom: 1px dashed #cccccc;">
                    <span style="margin-left: 40px;">主播等级</span>
                    <select name="conditionsValue" class="selconditions" style="width: 110px;margin-top: 5px;margin-left: 40px;">

                    </select>

                    <input name="level"  type="text" class="sellevel" placeholder="请输入数字" style="width: 200px;margin-top: 5px;margin-left: 40px;" >
                   <!-- <select name="level"  >
                        <option value="">请选择主播等级</option>
                    </select>-->
                    <div class="font font20" style="cursor: pointer; color: red; width: 22px;height: 22px;margin:0 0 -4px 10px;display: inline-block;"><span class="icon-minus-sign" onclick="removCondbox(this)"></span></div>
                </div>
            </div>
            <div id="conditionsclone2">

            </div>

        </div>
        <div><span>请拖动指针设置保底底薪比例：</span><span id="span_bin"></span></div>
        <div style="width: 660px;">
            <div style="margin-top: 45px;">
               <!-- <input  name="sivalue" type="hidden" class="single-slider" value="0" />-->
                <input type="number" name="sivalue" id="bedrooms" value="0" min="0" max="70" size="2" data-units="bedrooms" /><span>%</span>
            </div>

        </div>
    </form>
</div>

<div id="addExceptionDialog" style="display:none"> <!--class="ui-dialog"-->
  <div class="ui-dialog-header">
    <!-- <div class="title" style="margin-left: 20px;font-size: 14px;">
       选择主播：
    </div> -->
    <!-- <div style="width: 705px;height: 1px;border-bottom:1px dashed #cccccc;margin-top: 20px;"></div> -->
    <div class="title" style="margin: 20px 0 20px 20px;font-size: 14px;">
      请拖动指针设置分成比例：
    </div>
    <div id="pr_excvalue" class="clearfix" style="margin-top: 45px; margin-left: 10px">
      <input id="excvalue" type="text" style="width: 650px;height: 30px;border: 1px solid #cccccc;margin-left: 30px;">
    </div>
  </div>

  <div class="ui-dialog-content">

  </div>
</div>

<div id="addTotalialog" style="display:none">
    <form id="mofDialogDialogForm">
        <div class="row-fluid">
            <div style="padding-top: 40px;padding-left: 30px;"><input type="text" id="richRatio" onkeydown="onlyNum(this)"><span style="margin-left: 10px;">聊币</span></div>
        </div>
    </form>
</div>

<link rel="stylesheet" href="{{static_url('web/css/icon/style-icon.css')}}">
<link rel="stylesheet" href="{{static_url('web/css/jquery.range.css')}}">
<script type="text/javascript" src="{{static_url('web/js/jquery.range.js')}}"></script>


<script type="text/javascript">

$(function(){
    
  getDataList();
});

var btn_search=global.doc('btn_search');
utils.addEvent(btn_search,'click',function(){
    getDataList();
});

function getDataList(index){
    var form=global.doc('fiamlyform');
    var data={};
    data.userName=form.name.value;
    data.sort=1;
    data.page=index||1;
    data.pageSize=global.pageSize;
    data.type=1;
    $.ajax({
        type:"POST",
        data:data,
        url:'/ajax/userList',
        dataType:'json',
        success:function(res){
            var data=res.data;
            var tableList=document.getElementById("tableList");
            var tbody= tableList.getElementsByTagName('tbody')[0];
            dataTable.clearData(tbody);

            var count=document.getElementById('count');
            count.innerHTML=data.count;

            for(var i=0;i<data.list.length;i++){
                addRow(tbody,data.list[i]);
            }
            if(!index||index==0){
                utilsPagination("#pagination",data.count,global.pageSize,function(page_index,jq){
                    page_index+=1;
                    getDataList(page_index);
                });
            }
        }

    });
}


function addRow(table,data){

  var row=table.insertRow();
  var cell=row.insertCell(0);
  var cell1=row.insertCell(1);
  var cell2=row.insertCell(2);
  var cell3=row.insertCell(3);
  var cell4=row.insertCell(4);

  var div=document.createElement("div"),
    img=document.createElement("img"),
    span=document.createElement("span");

    div.className="anchor-info";
    img.src=global.contract+data.avatar;
    span.innerHTML=data.uid;

    div.appendChild(img);
    div.appendChild(span);

    cell.appendChild(div);

    cell1.innerHTML=data.nickName;   

    cell2.innerHTML=data.name;
    cell3.innerHTML=data.cash;
    
    
    var a=document.createElement("a");
    a.href='/pull/anchorinfo?uid='+data.uid;
    a.innerHTML="查看";
    a.className="a-edit font font18 cr-pe cursor-pointer";
    cell4.appendChild(a);
    return row;
}

function changeRatio(){
  $("#addExceptionDialog").dialog({
        autoOpen:true,
        width:750,
        height:350,
        title:'修改比例',
        resizable:false,
        modal:true,
        open:function(){
            setRange('pr_excvalue', $("#ratioNum").val());
        },
        buttons: {
            "确定": function () {
                var excvalue=$('#pr_excvalue').find('input[name="sivalue"]').val();//document.getElementById('excvalue').value;
                if(excvalue==''){
                    alert('请设置保底底薪比例');
                    return;
                }
                var data={};
                data.ratio = excvalue;
                $.ajax({
                    type:"POST",
                    data:data,
                    url:'/ajax/setRatio',
                    dataType:'json',
                    success:function(res){
                        if(res.code == 0) {
                            location.reload();
                        }else{
                            alert(res.info);
                        }
                    }
                });

            }
        }
    });
}

function setRange(doc, value){
    var rg = $('#'+doc);
    rg.html('<input name="sivalue" type="hidden" class="single-slider" value="0" />');
    rg.find('.single-slider')[0].value = value;
    rg.find('.single-slider').jRange({
        from: 0,
        to: 100,
        step: 1,
        scale: [0,10,20,30,40,50,60,70,80,90,100],
        format: '%s',
        width: 665,
        showLabels: true,
        showScale: true
    });
}

function totalCashRatio(){
    $("#addTotalialog").dialog({
        autoOpen:true,
        width:350,
        height:250,
        title:'修改每日限额',
        resizable:false,
        modal:true,
        open:function(){
            $('#richRatio').val($('#totalCash').attr('value'));
        },
        buttons: {
            "确定": function () {

                var data={};
                data.limitNum = $('#richRatio').val();
                data.type = 0;
                $.ajax({
                    type:"POST",
                    data:data,
                    url:'/ajax/setDayMaxLimit',
                    dataType:'json',
                    success:function(res){
                        if(res.code == 0) {
                            location.reload();
                        }else{
                            alert(res.info);
                        }
                    }
                });

            }
        }
    });
}
</script>